package com.itheima.ip;

import java.net.InetAddress;
import java.net.UnknownHostException;

/*
IP地址类
 */
public class Demo01 {
    public static void main(String[] args) throws UnknownHostException {
        //参数ip地址字符串
        //主机名
        //InetAddress ip = InetAddress.getByName("192.168.101.31");
        InetAddress ip = InetAddress.getByName("zhaichaojie");
        System.out.println(ip);
        //获取主机名
        String hostName = ip.getHostName();
        //获取ip地址
        String hostAddress = ip.getHostAddress();
        System.out.println(hostName);
        System.out.println(hostAddress);

    }


}
